<?
require_once ('../../models/Users.php');
$user = Users::GetAll();
?>


<!DOCTYPE html>
<html lang="en">
	<? include('../../inc/head.php'); ?>
	<body>
		<div>
			<? include('../../inc/nav.php'); ?>

			<div id="content">
				<h3>User Table</h3>
				<div id="content">
				<? if(isset($_GET['inserted'])): ?>
				    <div class="alert alert-success">
					    <button type="button" class="close">×</button>
					    A user has been successfuly added.
				    </div>
				<? endif; ?>
				<a href="create.php">+ Create New</a>
				
				<table class="table table-bordered table-condensed table-hover table-striped">
		
					<tr>
						<th>Id</th><th>First Name</th><th>Last Name</th><th>Created At</th><th>Updated At</th><th>Actions</th>
					</tr>
		
					<? while($row = $user->fetch_assoc()): ?>
						<tr>
							<td><?=$row['id']?></td><td><?=$row['FristName']?></td><td><?=$row['LastName']?></td><td><?=$row['created_at']?></td><td><?=$row['updated_at']?></td>
							<td>
								<a href="details.php?id=<?=$row['id']?>">Details</a>
								<a href="edit.php?id=<?=$row['id']?>">Edit</a>
								<a href="delete.php?id=<?=$row['id']?>">Delete</a>
							</td>					
						</tr>
					<? endwhile; ?>
				</table>
				
			</div>
			<? include('../../inc/footer.php'); ?>
		</div>
	</body>
</html>
